﻿@{
    Layout = "~/_SiteLayout.cshtml";
    string parentID = Request.QueryString["parentid"];
    
    
    if(IsPost)
    {
        string sort = Request.Form["sort"] ?? "";
        string[] sortArray = sort.Split(',');
        Business.Platform.Users busers = new Business.Platform.Users();
        for (int i = 0; i < sortArray.Length; i++)
        {
            Guid gid;
            if (!sortArray[i].IsGuid(out gid))
            {
                continue;
            }
            busers.UpdateSort(gid, i + 1);
        }
        <script type="text/javascript">
            parent.frames[0].reLoad('@parentID');
        </script>
    }

    var users = new Business.Platform.Organize().GetAllUsers(parentID.ToGuid());
}
    <form method="post">
    <div style="width:82%; margin:0 auto; height:auto;" id="sortdiv">
        @foreach(var user in users)
        {
        <ul class="sortul">
            <input type="hidden" value="@user.ID" name="sort" />
            @user.Name
        </ul>
        }
    </div>
    <div style="width:90%; text-align:center; margin:0 auto; margin-top:10px;">
        <input type="submit" class="mybutton" value="保存排序" onclick="" />
        <input type="button" class="mybutton" value="返回" onclick="re();" />
    </div>
    </form>
    <script type="text/javascript">
        var win = new RoadUI.Window();
        $(function ()
        {
            new RoadUI.DragSort($("#sortdiv"));
        });
        function re()
        {
            window.location = "User" + '@Request.Url.Query';
        }
    </script>